/*
 Xern Entity Relocation Network
 Copyright (C) 2011 Ronie Salgado <roniesalg@gmail.com>

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
*/

#ifndef XERNP_REGION_MESSAGES_HPP
#define XERNP_REGION_MESSAGES_HPP

#include "Message.hpp"

namespace XernProtocol
{
	/**
	 * Request a region list from the server.
	 */
	class RegionListRequest: public Message
	{
	public:
		virtual MessageType GetType() const;
		virtual size_t GetSize();
	};

	/**
	 * Region list response.
	 */
	class RegionListResponse: public Message
	{
	public:
		struct Entry
		{
			size_t GetSize()
			{
				return name.size() + basedata.size() + 21;
			}

			//u16 name_size;
			std::string name;
			//u16 basedata_size
			std::string basedata;
			uuid id;
			u8 flags;
		};

		typedef std::vector<Entry> Entries;

		RegionListResponse();
		~RegionListResponse();

		virtual MessageType GetType() const;
		virtual size_t GetSize();

		void Decode(DataStream &in, size_t size);
		void Encode(DataStream &out) const;

		u8 nummessages;
		u8 messageid;
		// u8 numentries;
		Entries entries;
	};

	/**
	 * Region full update request.
	 */
	class RegionFullUpdateRequest: public Message
	{
	public:
		static const size_t Size = 16;

		RegionFullUpdateRequest();
		~RegionFullUpdateRequest();

		virtual MessageType GetType() const;
		virtual size_t GetSize();

		virtual void Decode(DataStream &in, size_t size);
		virtual void Encode(DataStream &out) const;

		uuid regionId;
	};

}; // namespace XernProtocol

#endif // XERNP_REGION_MESSAGES_HPP
